import {Notification} from 'element-ui';
import Store from '../store';

const Func = {
    error(msg) {
        Notification.error({
            title: '错误',
            duration: '1500',
            message: msg
        });
    },

    success(msg) {
        return new Promise(resolve => {
            Notification({
                title: '成功',
                message: msg,
                type: 'success',
                duration: '1500',
                onClose: () => {
                    resolve();
                }
            });
        });
    },

    verify(code) {
        return new Promise((resolve) => {
            if(Store.state.user.rid == 1 || Store.state.rules.includes(code.toString())){
                resolve();
            }else{
                this.error('抱歉，您没有操作权限');
            }
        });
    }


};
export default Func;
